package com.base.cn.platform.os.controller.manage.work;

import com.base.cn.platform.os.common.controller.BaseController;
import com.base.cn.platform.os.common.utils.result.ResultUtil;
import com.base.cn.platform.os.entity.manage.work.SysWorkBlockSort;
import com.base.cn.platform.os.service.manage.work.SysWorkBlockSortBiz;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * 工作台模块排序
 *
 * @author s.li
 * @create 2018-04-16-9:47
 */
@RestController
@RequestMapping("/manage")
public class SysWorkBlockSortController extends BaseController {

    @Autowired
    private SysWorkBlockSortBiz sysWorkBlockSortBiz;

    /**
     * 保存工作台权限模块
     * @param userId 用户ID
     * @param sysWorkBlockSortList 数据列表
     * @return  Map<String,Object>
     */
    @RequestMapping("/saveSysWorkBlockSort")
    public Map<String,Object> saveSysWorkBlockSort(@RequestParam("userId") BigDecimal userId,
                                                   @RequestBody List<SysWorkBlockSort> sysWorkBlockSortList){
        sysWorkBlockSortBiz.saveSysWorkBlockSort(userId,sysWorkBlockSortList);
        return ResultUtil.SUCCESS("工作台权限块排序保存成功");
    }

    /**
     * 通过用户ID查询用户的工作台权限块排序
     * @param userId 用户ID
     * @return List<SysWorkBlockSort>
     */
    @RequestMapping("/findSysWorkBlockSortByUserId")
    public List<SysWorkBlockSort> findSysWorkBlockSortByUserId(@RequestParam("userId") BigDecimal userId){
        return sysWorkBlockSortBiz.findSysWorkBlockSortByUserId(userId);
    }
}
